//计算左侧是否有网格按钮，没有则下方定位置顶
		$(document).ready(function(){
			if(!$('.case_grid_box').length){
				$('.gridbox').css('top','0');
			}else{
				var H1=$('.case_grid_box').height()+12;
				$('.gridbox').css('top',H1+'px');
			}
			if(!$('#r-title').length){
				$('#r-map').css('top','0');
			}else{
				var H2=$('#r-title').height();
				$('#r-map').css('top',H2+'px');
			}
		});
		
		layui.use(['jquery', 'layer', 'form', 'element','flow'],function() {
			var form = layui.form;
			var $ = layui.jquery;
			var layer = layui.layer;
			var element = layui.element;//Tab的切换功能，切换事件监听等，需要依赖element模块
			 var flow = layui.flow;
			
			var submit = function() {
				return false;
			};
			//左侧流加载
			 flow.load({
			    elem: '#LAY_demo2' //流加载容器
			    ,scrollElem: '#LAY_demo2' //滚动条所在元素，一般不用填，此处只是演示需要。
			    ,done: function(page, next){ //执行下一页的回调
			      //模拟数据插入
			      setTimeout(function(){
			        var lis = [];
			        for(var i = 0; i < 8; i++){
//			          lis.push('<li>'+ ( (page-1)*8 + i + 1 ) +'</li>')
			          lis.push('<li class="staff-cell">'+
							   '<div class="staff-cell_hd">'+
							   '<img src="../../public/res/images/pgis/point30.png" />'+
								'</div>'+
								'<div class="staff-cell_bd">'+
								'<span>老地方饭店内发生诈骗案</span>'+
								'<span>广西壮族自治区贺州市平桂区西湾街道西发街60号老地方饭店</span>'+
								'</div>'+
								'</li>')
			        }
			        
			        //执行下一页渲染，第二参数为：满足“加载更多”的条件，即后面仍有分页
			        //pages为Ajax返回的总页数，只有当前页小于总页数的情况下，才会继续出现加载更多
			        next(lis.join(''), page < 10); //假设总页数为 10
			      }, 500);
			    }
			  });
			   flow.load({
			    elem: '#LAY_demo3' //流加载容器
			    ,scrollElem: '#LAY_demo3' //滚动条所在元素，一般不用填，此处只是演示需要。
			    ,done: function(page, next){ //执行下一页的回调
			      //模拟数据插入
			      setTimeout(function(){
			        var lis = [];
			        for(var i = 0; i < 8; i++){
//			          lis.push('<li>'+ ( (page-1)*8 + i + 1 ) +'</li>')
			          lis.push('<li class="staff-cell">'+
							   '<div class="staff-cell_hd">'+
							   '<img src="../../public/res/images/pgis/point30.png" />'+
								'</div>'+
								'<div class="staff-cell_bd">'+
								'<span>老地方饭店内发生诈骗案</span>'+
								'<span>广西壮族自治区贺州市平桂区西湾街道西发街60号老地方饭店</span>'+
								'</div>'+
								'</li>')
			        }
			        
			        //执行下一页渲染，第二参数为：满足“加载更多”的条件，即后面仍有分页
			        //pages为Ajax返回的总页数，只有当前页小于总页数的情况下，才会继续出现加载更多
			        next(lis.join(''), page < 10); //假设总页数为 10
			      }, 500);
			    }
			  });
			
			
			//删除百度地图左下角原生提示，如用3D地图，可删除该行代码
		  $('.anchorBL').remove();
			
			//左侧面板伸缩事件
			$('.flex-icon').click(function() {
				$(this).find('.zkuasgm-icon').toggleClass('close');		
				$(this).find('.zkuasgm-icon').toggleClass('open');		//点击位置的icon的切换
				var para=$('#move-left').css("display");
				if(para=='block'){
					$("#move-right").animate({
						width: "auto",
						left:"65px"
					}, {
						queue: false,
						duration: 100
					});
					if($('.case_grid_box').length){
						$('.gridbox').css('top','90px');
					}else{
						$('.gridbox').css('top','0px');
					}
					
				}else{
					$("#move-right").animate({
						width: "auto",
						left:"316px"
					}, {
						queue: false,
						duration: 100
					});
					if($('.case_grid_box').length){
						$('.gridbox').css('top','50px');
					}else{
						$('.gridbox').css('top','0px');
					}
				}
				$('#move-left').stop().animate({				//左侧面板伸缩动画
					width: 'toggle',
					opacity: 'toggle'
				}, {
					queue: false,
					duration: 300
				});
				
				$('.case_grid_box').find('button').toggleClass('hide');
				$('.par-box').toggleClass('menuClose');
				$('.par-box').toggleClass('menuOpen');
			});
			
			//点击常用工具及地图工具侧边弹出对应侧栏
			$('.toolbar').find('li').click(function(){
				$('.flex-icon').find('.zkuasgm-icon').removeClass('close');		
				$('.flex-icon').find('.zkuasgm-icon').addClass('open');	
				$("#move-right").animate({
					width: "auto",
					left:"316px"
				}, {
					queue: false,
					duration: 300
				});
				$('#move-left').show();
				$(this).addClass('active');
				$(this).siblings().removeClass('active');
				var targetId=$(this).attr('target-name');
				$('#'+targetId+'').show();
				$('#'+targetId+'').siblings().hide();
				
				var tips = layer.tips();
				layer.close(tips);
				
				$('.case_grid_box').find('.btn1').addClass('hide');
				$('.case_grid_box').find('.btn2').removeClass('hide');
				
				$('.par-box').removeClass('menuClose');
				if($('.case_grid_box').length){
					$('.gridbox').css('top','50px');
				}else{
					$('.gridbox').css('top','0px');
				}
			});
			
//			$(document).on('click', '.selected-btn', function() {
//				$(this).addClass('active');
//			});
			
			var moreContentIndex;
			
			//点击常用工具及地图工具中按钮样式及状态切换
		    $(".grid-btn").click(function (e) {
		    	if(!$(this).hasClass('prohibit-btn')){
		    		$(this).parent().parent().parent().find('.grid-btn').removeClass('active');
			        $(this).addClass('active');
			
			        if($(this).parentsUntil(".layui-layer-wrap").is("html")){
			            moreContentIndex && layer.close(moreContentIndex);
			        }
			
			        e.stopPropagation();
		    	}
		    });
		
		    $('.layui-tab').click(function () {
		        moreContentIndex && layer.close(moreContentIndex);
		    });
		    //地图工具多级工具按钮
		    $('.choose-more').click(function (e) {
		        moreContentIndex && layer.close(moreContentIndex);
		        let $this = $(this);
		        let offset = $this.offset();
		        var $content = $this.parent().children(".more-content");
		        moreContentIndex = layer.open({
		            type: 1,
		            shadeClose: true,
		            shade: false,
		            closeBtn: 1,
		            title: false,
		            offset: [offset.top + 50 +'px', offset.left + 50 + 'px'],
		            // area: ['400px'],
		            zIndex: 1000,
		            content: $content,
		            success: function(layero, index){
		            },
		            cancel: function(layero, index){
		            },
		        });
		        e.stopPropagation();
		
		    });
			
//			$('.type-box').find('li').click(function(){
//				$(this).addClass('active');
//				$(this).siblings().removeClass('active');
//				var targetId=$(this).attr('target-name');
//				$('#'+targetId+'').siblings('.select-box').slideUp();
//				$('#'+targetId+'').slideToggle();
//			})
			
		//网格弹窗
			$('[name="searBtn1"]').on({
				click:function(){
					layer.closeAll();
					var $grid_content = $(".grid_layer");
					layer.open({
					  type: 1,
					  title: '选择网格',
					  shadeClose: true,
					  shade: 0,
					  area: ['80%', '70%'],
					  content: $grid_content
					});
//					Slide('grid');//tab的滑动插件
//					TabMove('grid');
					treeH('grid');
				}
			});
			//业务弹窗
			$('[name="searBtn2"]').on({
				click:function(){
					layer.closeAll();
					var $business_content = $(".business_layer");
					layer.open({
					  type: 1,
					  title: '选择业务',
					  shadeClose: true,
					  shade: 0,
					  area: ['80%', '70%'],
					  content: $business_content
					});
//					Slide('business');//tab的滑动插件
//					TabMove('business');
					treeH('business');
				}
			});
			
//			计算弹框树状图内容边距;业务跟网格
			function treeH(param){
				var topH=$('#'+param+'_layer').find('.tabList').height()+85;
				var treeH='calc(100% - '+topH+'px)';
				console.log($('#'+param+'_layer').find('.lf-flow'));
				$('[name="'+param+'_swiper2"]').css('height',treeH);
			}
			
			//全屏监听
		    $("#full-screen").click(function () {
		        var docElm = window.frameElement;
		        var elm = document.documentElement;
		        var requestMethod = elm.requestFullScreen || elm.webkitRequestFullScreen || elm.mozRequestFullScreen || elm.msRequestFullscreen;
		        if (elm.msRequestFullscreen) {
		            elm = docElm;
		        }
		        requestMethod.call(elm);
		
		        if (!isFullscreenForNoScroll()) {
		            (docElm.requestFullscreen && docElm.requestFullscreen()) ||
		            (docElm.mozRequestFullScreen && docElm.mozRequestFullScreen()) ||
		            (docElm.webkitRequestFullscreen && docElm.webkitRequestFullscreen()) ||
		            (docElm.msRequestFullscreen && docElm.msRequestFullscreen());
		        } else {
		            // 判断各种浏览器，找到正确的方法
		            document.exitFullscreen ? document.exitFullscreen() :
		                document.mozCancelFullScreen ? document.mozCancelFullScreen() :
		                    document.webkitExitFullscreen ? document.webkitExitFullscreen() : '';
		        }
		        function isFullscreenForNoScroll() {
		            return document.fullScreen || document.mozFullScreen || document.webkitIsFullScreen;
		        }
		    });
		});
		
		$(document).on('click','.tabList li',function(){
			$(this).toggleClass('active');
			$(this).siblings().removeClass('active');
		});
		
			//右上角事件、摄像图、物联网按钮弹窗事件
//			$('.btn-box').find('button').click(function(){
//				var targetId=$(this).attr('target-name');
//				var tpml=$('#'+targetId+'').html();
//				var title=$(this).attr('name');
//				layer.open({
//				  type: 1,
//				  skin: 'layui-layer-rim', //加上边框
//				  title:title+'信息',
//				  area: ['400px', '300px'], //宽高
//				  content: tpml,
//				  shade: 0,
//                offset: 'rb'
//				});
//			});
		//右上角消息提醒按钮
		$('.btn-box').find('.remind-btn').click(function(){
			var LIlength=$('#remindList li').length;
			if(LIlength>0){
				$(".remind-ul").slideToggle(200);
			}else{
				layer.closeAll('page');
				var tpml=$('#remindTpml').html();
				layer.open({
					type: 1,
					skin: 'layui-layer-rim', //加上边框
					title:'消息',
					area: ['500px', '300px'], //宽高
					content: tpml,
					shade: 0,
	                offset: 'rb'
				});
			}
			
		});
		function initRemind(docName){
			var LIlength=$('#remindList li').length;
			if(LIlength>0){
				var $icon=$('#remindList li:last-child>.zkuasgm-icon');
				var tpml = $icon.clone(true);
				$('.remind-btn').html(tpml);
			}else{
				$('.remind-btn').removeClass('scaleDrawbtn');
				$('.remind-btn').html('<i class="zkuasgm-icon">&#xe6b9;</i>');
			}
		}
		
		$('#remindList li').click(function(){
			var tt=$(this).attr('target-name');
			$(this).remove();
			initRemind(tt);
			layer.closeAll('page');
			var tpml=$('#remindTpml').html();
			layer.open({
				type: 1,
				skin: 'layui-layer-rim', //加上边框
				title:'信息',
				area: ['500px', '300px'], //宽高
				content: tpml,
				shade: 0,
                offset: 'rb'
			});
			$('[hd-name="'+tt+'"]').addClass('active').siblings().removeClass('active');
			$('[hd-name="'+tt+'"]').find('.layui-badge').removeClass('scaleDrawbtn');
			$('[ct-name="'+tt+'"]').removeClass('hide').siblings().addClass('hide');
			
			var t_a = $('.layui-layer-content').find('[hd-name="'+tt+'"]').offset().top;
			var aa=$('.layui-layer-content .rd-tabHd').offset().top;
			var t_h=$('.layui-layer-content .rd-tabHd').scrollTop();
			var t_SH= t_h+t_a-aa;
			$('.layui-layer-content .rd-tabHd').animate({scrollTop:t_SH+ "px"}, 500);
			
		});
		
		
		$(document).on('click','.rd-tabHd li',function(){
			var tt=$(this).attr('hd-name');
			$('[hd-name="'+tt+'"]').addClass('active').siblings().removeClass('active');
			$('[hd-name="'+tt+'"]').find('.layui-badge').removeClass('scaleDrawbtn');
			$('[ct-name="'+tt+'"]').removeClass('hide').siblings().addClass('hide');
			
			$('[target-name="'+tt+'"]').remove();
			initRemind(tt);
		});
		
		$(document).on('click','.rd-tabContent li',function(){
			$(this).addClass('active').siblings().removeClass('active');
			
			
			 $(".remind-tips").show();
		});
		
		
//		信用
		$(document).on('click','.Tax-box li',function(){
			$(this).addClass('active').siblings().removeClass('active');
		});
		$('[lay-event="layer2"]').click(function(){
			$('.Tax-box').show();
			layer.open({
				  type: 2,
				  title: '弹框4',
				  offset:['150px','320px'],
				  shade: false,
				  area: ['400px', '60%'],
				  content: 'Tax/info2.html', //iframe的url
				  cancel: function (index, layero) {//取消事件
				  	$('.Tax-box').hide();
				  }
			}); 
		});
		$('[event="layer"]').click(function(){
			var layerContent=$(this).attr('name');
			layer.open({
			  type: 2,
			  title: '弹框'+layerContent,
			  shadeClose: true,
			  shade: 0.4,
			  area: ['60%', '60%'],
			  content: 'Tax/'+layerContent+'.html' //iframe的url
			}); 
		});
		
		$('[lay-event="layer"]').click(function(){
			layer.open({
			  type: 2,
			  title: '弹框4',
			  offset:'r',
			  shade: false,
			  area: ['350px', '60%'],
			  content: 'Tax/info4.html' //iframe的url
			}); 
		})
//		信用end

		// 百度地图API功能
		var map = new BMap.Map("allmap"); //创建百度地图实例，这里的allmap是地图容器的id
		var point = new BMap.Point(110.298537, 25.271245); //创建一个点对象，这里的参数是地图上的经纬度
		map.centerAndZoom(point, 15); //这里是将地图的中心移动到我们刚才创建的点；这里的12是地图的缩放界别；数值越大，地图看的越细
//		var opts2={mapTypes:[BMAP_NORMAL_MAP,BMAP_PERSPECTIVE_MAP,BMAP_HYBRID_MAP,BMAP_SATELLITE_MAP]};
//		map.addControl(new BMap.MapTypeControl(opts2));   //添加地图类型控件
		// 添加带有定位的导航控件
		  var navigationControl = new BMap.NavigationControl({
		    // 靠右上角位置
		    anchor: BMAP_ANCHOR_TOP_RIGHT ,
		    // LARGE类型
		    type: BMAP_NAVIGATION_CONTROL_SMALL ,
		    // 启用显示定位
		    enableGeolocation: true
		  });
		  //map.addControl(navigationControl);
		  // 添加定位控件
		  var geolocationControl = new BMap.GeolocationControl({
		  	anchor: BMAP_ANCHOR_TOP_RIGHT,
		  	offset: new BMap.Size(8, 130)
		  });
		  geolocationControl.addEventListener("locationSuccess", function(e){
		    // 定位成功事件
		    var address = '';
		    address += e.addressComponent.province;
		    address += e.addressComponent.city;
		    address += e.addressComponent.district;
		    address += e.addressComponent.street;
		    address += e.addressComponent.streetNumber;
		    alert("当前定位地址为：" + address);
		  });
		  geolocationControl.addEventListener("locationError",function(e){
		    // 定位失败事件
		    alert(e.message);
		  });
		  //map.addControl(geolocationControl);
		  map.enableScrollWheelZoom(true);
		  


		$('.toolsbox .toolBtn').click(function(){
			$(this).siblings('.mapTool').toggle();
			$(this).parent('li').siblings().find('.mapTool').hide();
		});
		
		
		$(document).on('click','.mapTool .zk-close',function(){
			$('#suggestId').val('');
		});
		$(document).on('mouseover','.mapTool .zk-line',function(){
			layer.tips('路线', '#line-btn', {
			  tips: 3,
			  time:1500
			});
		});
		$(document).on('click','.mapTool .zk-line',function(){
			$('#single-line').hide();
			$('#between-line').show();
		});
		$(document).on('click','.mapTool .cancel-button',function(){
			$('#single-line').show();
			$('#between-line').hide();
		});
		$(document).on('click','.input-clear',function(){
			$(this).siblings('input').val('');
		});
		$(document).on('click','.routebox-revert-icon',function(){
			var startVal=$('.route-start-input').val();
			var endVal=$('.route-end-input').val();
			$('.route-start-input').val(endVal);
			$('.route-end-input').val(startVal);
		});
		$(document).on('click','.route-tabs .tab-item',function(){
			$(this).addClass('active').siblings().removeClass('active');
		});

		$('[name="drawBtn"]').click(function(){
			$('.floated').toggle();
		});
		
		$('[name="searchBtn"]').click(function(){
			$('.mapsearchList').show();
		});
		